<jsp:useBean id="userManager" scope="application" class="org.languageguide.user.UserManager" /><html>
<head>
</head>
<body>
<%
	String email = request.getParameter("email");
	String password = request.getParameter("password");
	System.out.println(email + " what " + password);
	boolean 	success = userManager.loadUser(session, email, password);
	String message = "Welcome!";
	session.setAttribute("message", message);
	if (!success){
		response.sendRedirect("/user/login.jsp");
	}
	else{
		String remember = request.getParameter("remember");
		System.out.println("remember" + remember);
		if (remember != null){
			userManager.rememberUser(session, response);
		}	
		Object redirect = session.getAttribute("redirect_url");
		if (redirect != null){
			System.out.println("redirect " + redirect);
			session.removeAttribute("redirect_url");
			response.sendRedirect((String)redirect);
		}
		else{
			String referer = request.getParameter("referer");
			System.out.println("referer" + referer);
			if (referer != null){
				response.sendRedirect(referer);
			}
			else{
				response.sendRedirect("../wiki/");
			}
		}
	}
%>
</body>
</html>